package com.macro.mall.common.exception;

import com.macro.mall.common.utils.BizInfo;

public class BizException extends RuntimeException {
    protected int code;
    protected String msg;

    public BizException(BizInfo bizInfo) {
        this(bizInfo.code(), bizInfo.msg());
    }

    public BizException(BizInfo bizInfo, String msg) {
        this(bizInfo.code(), msg);
    }

    public BizException(int code, String msg) {
        this(code, msg, (Throwable)null);
    }

    public BizException(int code, String msg, Throwable cause) {
        super(msg, cause);
        this.code = code;
        this.msg = msg;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getCode() {
        return this.code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getMsg() {
        return this.msg;
    }

    public String getDetailMessage() {
        return String.format("[code]: '%d'. [msg]: '%s'", this.code, this.msg);
    }
}
